package org.feidao.chapter63.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;

import lombok.extern.slf4j.Slf4j;

/**
 * Created by linghufeixia on 2022-11-8.
 * 消费者service
 */
@Service
@Slf4j
public class ConsumerService {
    public static final String topic = "test";

    @Autowired
    private KafkaTemplate<?,String> kafkaTemplate;

    //从topic接收消息
    @KafkaListener(topics = "test", groupId = "testGroup", topicPartitions = {})
    public void receiveMessage(String message) {
        log.info("receive:" + message);
    }
}
